package com.huitian.mobileshop;

import android.app.ProgressDialog;
import android.content.Context;
import android.graphics.Bitmap;
import android.webkit.WebView;
import android.webkit.WebViewClient;

class MyWebClient extends WebViewClient{
	
		public ProgressDialog pd ;
	
        public MyWebClient(Context context){
        	pd=new ProgressDialog(context);
        	pd.setTitle("请稍候");
        	pd.setMessage("正在打开，请稍候...");
        }
		@Override
		public boolean shouldOverrideUrlLoading(WebView view, String url) {
			view.loadUrl(url);
			return true;
		}
		public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) {
			 super.onReceivedError(view, errorCode, description, failingUrl);
			 	view.getSettings().setDefaultTextEncodingName("UTF-8");
		        view.loadData("访问服务器遇见未知错误，请联系服务提供商", "text/html; charset=utf-8", "utf-8");
		}
		
		@Override
		public void onPageStarted(WebView view, String url, Bitmap favicon) {
		// TODO Auto-generated method stub
			super.onPageStarted(view, url, favicon);
			pd.show();
		}
		@Override
		public void onPageFinished(WebView view, String url) {
		// TODO Auto-generated method stub
			super.onPageFinished(view, url);
			pd.cancel();
		}
	}